//
//  MyImageView.m
//  03-17-小人快跑
//
//  Created by student on 16/3/20.
//  Copyright © 2016年 niit. All rights reserved.
//

#import "MyImageView.h"

@implementation MyImageView

-(UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
{
    //判断一下触摸点是不是在imageView范围内
    
    CGPoint imageViewPoint=[self convertPoint:point toView:self];
    if ([self pointInside:imageViewPoint withEvent:event]) {
        return self;
    }
    else
    {
        return [super hitTest:point withEvent:event];
    }
}
-(void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    UITouch *touch=[touches anyObject];
    
    //当前视图中的触摸点
    CGPoint curPoint=[touch locationInView:self];
    //上次的点
    CGPoint perPoint=[touch previousLocationInView:self];
    //偏移量
    
    CGFloat offsetX=curPoint.x-perPoint.x;
    CGFloat offsetY=curPoint.y-perPoint.y;
    
    self.center=CGPointMake(self.center.x+offsetX, self.center.y+offsetY);
}


@end
